package com.cskaoyan.service;
import com.cskaoyan.bean.vo.WxIndexVO;
import com.cskaoyan.bean.vo.WxIndex_VO;
import com.cskaoyan.mapper.MarketUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author : qj
 * @since: 2022/10/14  18:22
 */
@Service
public class WxUserServiceImpl implements WxUserService {
    @Autowired
    MarketUserMapper marketUserMapper;

    @Override
    public WxIndex_VO getIndex() {
        WxIndexVO[] wxIndexVOS = marketUserMapper.selectWxIndexVO();
         Integer unrecv = 0;
         Integer uncomment = 0;
         Integer unpaid = 0;
         Integer unship = 0;
        for (WxIndexVO wxIndexVO : wxIndexVOS) {
            if (wxIndexVO.getOrder_status() == 101){
                unpaid += wxIndexVO.getStatusAmount();
            }
            if (wxIndexVO.getOrder_status() == 201 ){
                unship += wxIndexVO.getStatusAmount();
            }
            if (wxIndexVO.getOrder_status() == 301 || wxIndexVO.getOrder_status() == 202){
                unrecv += wxIndexVO.getStatusAmount();
            }
            if(wxIndexVO.getOrder_status() == 401){
                uncomment += wxIndexVO.getStatusAmount();
            }
        }
        WxIndex_VO.OrderBean orderBean = new WxIndex_VO.OrderBean();
        orderBean.setUncomment(uncomment);
        orderBean.setUnpaid(unpaid);
        orderBean.setUnship(unship);
        orderBean.setUnrecv(unrecv);
        WxIndex_VO wxIndex_vo = new WxIndex_VO();
        wxIndex_vo.setOrder(orderBean);
        return wxIndex_vo;
    }
}
